package com.jiangnan.constants;

import com.jiangnan.utils.ImageUtils;

import javax.swing.*;
import java.net.URL;

/**
 * 顶部的按钮
 *
 * @author chenliang
 * @email wschenliang@aliyun.com
 */
public class MainButton {
    public static MainButton
            SETTINGS = new MainButton("系统设置", MainButton.class.getResource("/image/button/settings.png")),
            MESSAGE = new MainButton("消息", MainButton.class.getResource("/image/button/message.png")),
            ADVICE = new MainButton("通知", MainButton.class.getResource("/image/button/advice.png")),
            DATABASE = new MainButton("数据库", MainButton.class.getResource("/image/button/database.png")),
            SIGN_IN = new MainButton("签到", MainButton.class.getResource("/image/button/sign_in.png")),
            FACE_REC = new MainButton("人脸识别", MainButton.class.getResource("/image/button/face_recognition.png")),
            MENU = new MainButton("菜单", MainButton.class.getResource("/image/button/menu.png")),
            CLASS_MANAGEMENT = new MainButton("班级管理", MainButton.class.getResource("/image/button/class_management.png")),
            ATTENDANCE_MANAGEMENT = new MainButton("考勤管理", MainButton.class.getResource("/image/button/attendance_management.png")),
            FACE = new MainButton("人脸", MainButton.class.getResource("/image/button/face.png"));

    private String text;//按钮填充文字
    private URL iconUrl;//按钮图片链接

    MainButton(String text, URL iconUrl) {
        this.text = text;
        this.iconUrl = iconUrl;
    }

    public URL getIconUrl() {
        return iconUrl;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Icon getIcon() {
        if (iconUrl == null) {
            return null;
        }
        ImageIcon imageIcon = new ImageIcon(iconUrl);
        return ImageUtils.resizedImage(imageIcon);
    }

    public void setIconUrl(URL iconUrl) {
        this.iconUrl = iconUrl;
    }
}
